feat(claude): source model list from cc-switch, gated by env#927
feat(claude): source model list from cc-switch, gated by env#9278liang wants to merge 2 commits into
Conversation
Read the claude provider model list from cc-switch's current claude provider (alias→real-model mapping in settings_config.env) instead of the static fallback. The OPTIONS value stays a CLI alias (opus/sonnet/haiku/fable) that cc-switch's proxy rewrites; the label surfaces the real model name. Gated behind CLAUDE_CC_SWITCH_MODELS_ENABLED (default false) with CLAUDE_CC_SWITCH_DB_PATH overriding the default ~/.cc-switch/cc-switch.db. Falls back to the static list when disabled, the DB is missing, or no aliases are configured. Documented in .env.example.
📝 WalkthroughWalkthroughAdds an optional cc-switch proxy integration to Changescc-switch model alias integration
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
server/modules/providers/tests/claude-models.test.ts (1)
136-136: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert on fallback contents, not object identity.
getSupportedModels()only promises aProviderModelsDefinition; returning the sharedCLAUDE_FALLBACK_MODELSobject is just the current implementation. Theseassert.equal(...)checks will fail on a behavior-preserving clone.Proposed fix
- assert.equal(result, CLAUDE_FALLBACK_MODELS); + assert.deepEqual(result, CLAUDE_FALLBACK_MODELS);Also applies to: 147-147, 157-157
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server/modules/providers/tests/claude-models.test.ts` at line 136, The tests for `getSupportedModels()` are asserting object identity against `CLAUDE_FALLBACK_MODELS`, which is an implementation detail and will fail if the function returns an equivalent clone. Update the assertions in `claude-models.test.ts` to compare the fallback model contents/shape instead of using `assert.equal` on the shared constant, so the checks validate the returned `ProviderModelsDefinition` behavior rather than the exact object instance.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/modules/providers/tests/claude-models.test.ts`:
- Around line 112-122: The test in ClaudeProviderModels is not restoring the
previous CLAUDE_CC_SWITCH_DB_PATH value and instead always deletes it, which can
leak or clobber parent process state. In the test around withCcSwitchEnabled()
and new ClaudeProviderModels().getSupportedModels(), snapshot the existing
environment value before setting customDbPath, then in the finally block restore
that original value (or delete it only if it was unset) just like
withCcSwitchEnabled() does.
---
Nitpick comments:
In `@server/modules/providers/tests/claude-models.test.ts`:
- Line 136: The tests for `getSupportedModels()` are asserting object identity
against `CLAUDE_FALLBACK_MODELS`, which is an implementation detail and will
fail if the function returns an equivalent clone. Update the assertions in
`claude-models.test.ts` to compare the fallback model contents/shape instead of
using `assert.equal` on the shared constant, so the checks validate the returned
`ProviderModelsDefinition` behavior rather than the exact object instance.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a2c964a3-c383-4159-a9b7-14a4333b11ae
📒 Files selected for processing (3)
.env.exampleserver/modules/providers/list/claude/claude-models.provider.tsserver/modules/providers/tests/claude-models.test.ts
Read the claude provider model list from cc-switch's current claude provider (alias→real-model mapping in settings_config.env) instead of the static fallback. The OPTIONS value stays a CLI alias (opus/sonnet/haiku/fable) that cc-switch's proxy rewrites; the label surfaces the real model name.
Gated behind CLAUDE_CC_SWITCH_MODELS_ENABLED (default false) with CLAUDE_CC_SWITCH_DB_PATH overriding the default ~/.cc-switch/cc-switch.db. Falls back to the static list when disabled, the DB is missing, or no aliases are configured. Documented in .env.example.
Summary by CodeRabbit